package com.elitel.common.businessJdbc.mysql;

import com.elitel.common.businessJdbc.BusinessScriptPreparedStatement;

// here is for mysql version
public class MysqlScriptPreparedStatement extends BusinessScriptPreparedStatement{

    @Override
    public String getPrecompileSql() {
        // useing mysql Test
        StringBuilder sb = new StringBuilder();
        sb.append("select a.* from ( ")
            .append(getSqlWithPlaceHolder())
            .append(" ) a");
        if(isPageable()){
            sb.append(containPageableSqlSection());
        }

        return sb.toString();
    }

    public String containPageableSqlSection(){
        StringBuilder sb = new StringBuilder();
        sb.append(" LIMIT ")
            .append(getPageNumber() - 1)
            .append(",")
            .append(getPageSize());
        return sb.toString();
    }



}
